﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace CPPEI.Coolzon.UI
{
    public partial class ScenePart
    {
        private double _destHLoopOffset;

        /// <summary>
        /// 当前水平滚动的偏移值
        /// </summary>
        public double DestHLoopOffset
        {
            get
            {
                return _destHLoopOffset;
            }
        }

        public double CurrentHLoopOffset
        {
            get
            {
                return (double)GetValue(CurrentHLoopOffsetProperty);
            }
            set
            {
                SetValue(CurrentHLoopOffsetProperty, value);
            }
        }
        public static DependencyProperty CurrentHLoopOffsetProperty = DependencyProperty.Register("CurrentHLoopOffset",
            typeof(double),
            typeof(ScenePart),
            new PropertyMetadata(default(double), CurrentHLoopOffsetPropertyChangedCallback));

        private static void CurrentHLoopOffsetPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ScenePart part = d as ScenePart;
            part.RaisePropertyChanged(e.Property.Name);
            part.UpdateLoopRenderState(part.CurrentHLoopOffset);
        }


        public double HActualLoopOffset
        {
            get
            {
                return (double)GetValue(HActualLoopOffsetProperty);
            }
            set
            {
                SetValue(HActualLoopOffsetProperty, value);
            }
        }
        public static DependencyProperty HActualLoopOffsetProperty = DependencyProperty.Register("HActualLoopOffset",
            typeof(double),
            typeof(ScenePart),
            null);

        public double HVirtualLoopOffset
        {
            get
            {
                return (double)GetValue(HVirtualLoopOffsetProperty);
            }
            set
            {
                SetValue(HVirtualLoopOffsetProperty, value);
            }
        }
        public static DependencyProperty HVirtualLoopOffsetProperty = DependencyProperty.Register("HVirtualLoopOffset",
            typeof(double),
            typeof(ScenePart),
            null);

        /// <summary>
        /// 是否水平循环显示
        /// </summary>
        public bool IsHorizontalLoopRender
        {
            get
            {
                return (bool)GetValue(IsHorizontalLoopRenderProperty);
            }
            set
            {
                SetValue(IsHorizontalLoopRenderProperty, value);
            }
        }

        public static DependencyProperty IsHorizontalLoopRenderProperty = DependencyProperty.Register("IsHorizontalLoopRender",
            typeof(bool),
            typeof(ScenePart),
            new PropertyMetadata(default(bool), _OnIsHorizontalLoopRenderPropertyChangedCallback));

        private static void _OnIsHorizontalLoopRenderPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ScenePart part = d as ScenePart;
            part.RaisePropertyChanged(e.Property.Name);
        }
    }
}
